import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Cache } from "../../../cache/Cache";
import { Language } from "../../../../../extend/language/Language";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { ResFileConst } from "../../../resource/ResFileConst";
import { PloughInfoItem } from "./PloughInfoItem";
import { ScrollPolicy } from "../../../../../flashx/textLayout/container/ScrollPolicy";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { TextArea } from "../../../../../fl/controls/TextArea";
type int = number;
//class PloughCopyWindow
    
    export  class PloughCopyWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._ploughList = [];
            this._index = Cache.instance.ploughCopy.firstIndex;
            setSize(758, 522);
            titleHeight = 28;
            title = Language.getString(36680);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            addChild(new GImageBitmap(ImagesConst.ploughWindowBg, 15, 38));
            this._leftBtn = ObjCreate.createGLoadedButton(ResFileConst.MountStartLeft, 17, 245, 30, 30, this);
            this._leftBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onLeftBtnClickHandler);
            this._rightBtn = ObjCreate.createGLoadedButton(ResFileConst.MountStartRight, 715, 245, 30, 30, this);
            this._rightBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onRightBtnClickHandler);
            this._tileList = ObjCreate.createTileList(47, 45, 670, 435, this);
            this._tileList.columnWidth = 224;
            this._tileList.rowHeight = 430;
            this._tileList.columnCount = 3;
            this._tileList.rowCount = 1;
            this._tileList.setStyle("cellRenderer", PloughInfoItem);
            this._tileList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._tileList.verticalScrollPolicy = ScrollPolicy.OFF;
            addChild(this._tileList);
            var loc1=Language.getString(36683);
            this._introTxt = ObjCreate.createTextArea("", 80, 470, 625, 40, this);
            this._introTxt.htmlText = loc1;
            this._ploughList = Cache.instance.ploughCopy.ploughCopyAry;
            this.updatePloughData();
            return;
        }

        /* internal  */onLeftBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._index > 0) 
            {
                --this._index;
                this.updatePloughData();
            }
            return;
        }

        /* internal  */onRightBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._index < this._ploughList.length - 3) 
            {
                this._index = this._index + 1;
                this.updatePloughData();
            }
            return;
        }

        /* internal  */updatePloughData(): void
        {
            var loc1=Cache.instance.ploughCopy.getPloughCopyByIndex(this._index, this._index + 3);
            this._tileList.dataProvider = new DataProvider(loc1);
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this._index = Cache.instance.ploughCopy.firstIndex;
            this.updatePloughData();
            return;
        }

        /* internal */ /* var */_leftBtn: GLoadedButton;

        /* internal */ /* var */_rightBtn: GLoadedButton;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_ploughList: Array<any>;

        /* internal */ /* var */_introTxt: TextArea;

        /* internal */ /* var */_index: int;
    }
